<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('设置新增')"/>
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label my-red-star">键</label>
                    <div class="layui-input-block">
                        <input type="text" name="setKey" th:value="${sysSet.setKey}" lay-verify="required"
                               autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">值</label>
                    <div class="layui-input-block">
                        <textarea type="text" th:text="${sysSet.setValue}" name="setValue" class="layui-textarea">
                        </textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea type="text" th:text="${sysSet.remark}" placeholder="请输入内容" name="remark"
                                  class="layui-textarea">
                        </textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn submit pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery', 'dtree', 'button', 'popup'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let dtree = layui.dtree;
        var button = layui.button;
        var popup = layui.popup;


        form.on('submit(user-save)', function (data) {
            let btn = button.load({elem: '.submit'});
            $.ajax({
                url: suffix + '/system/set/save',
                data: data.field,
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    btn.stop(function () {
                        if (result.success) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                                parent.layui.table.reload("user-table");
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    })
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
